package com.jie.creator.singleton.demo06;
/**
 * @description:懒汉式:静态内部类
 * @author: jie
 * @time: 2022/1/29 17:47
 */
public class Singleton {

    /**
     * @description:私有构造方法，避免外部创建对象
     */
    private Singleton() {}
    /**
     * @description:定义一个静态内部类
     */
    private static class SingletonHolder {
        //在内部类中声明并初始化外部类的对象
        private static final Singleton INSTANCE = new Singleton();
    }

    /**
     * @description:对外提供静态方法获取该对象
     */
    public static Singleton getInstance() {
        return SingletonHolder.INSTANCE;
    }
}